package com.man.controller;


import com.man.common.Result;
import com.man.pojo.HistoryMessageDTO;
import com.man.pojo.MessageRequest;
import com.man.service.DpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/deepseek")
@Slf4j
public class DeepSeekController {

    @Autowired
    private DpService dpService;

    /**
     * 发送消息
     * @param request   请求体
     * @return          返回结果
     */
    @PostMapping("/sendMessages")
    public Result<String> sendMessages(@RequestBody MessageRequest request) {
        return dpService.sendMessages(request.getContent(), request.getUsername());
    }

    /**
     * 获取历史消息
     * @param username  用户名
     * @return          返回结果
     */
    @GetMapping("/getHistoryMessages")
    public Result<List<HistoryMessageDTO>> getHistoryMessages(@RequestParam String username) {
        return dpService.getHistoryMessages(username);
    }
}
